#define __CMT_C__
#include "cmt.h"
/*
function: 2ms timer initialize
*/

void cmt_init(void)
{
	/*open the cmt0*/
	SYSTEM.MSTPCRA.BIT.MSTPA15= 0;
	CMT.CMSTR0.BIT.STR0 = 0;
	/*clk=PCLK/128=390625Hz,enable interrupt*/
	CMT0.CMCR.WORD = 0x42;
	/*2ms */
	CMT0.CMCOR=390625/250;

	IR(CMT0,CMI0) = 0;
	IPR(CMT0,CMI0) = 1;
	/*enable interrupt*/
	IEN(CMT0,CMI0) = 1;
	CMT.CMSTR0.BIT.STR0 = 1;
}


